<template>
<div class="main">
   <div class="main-header">
     <img src="@/assets/images/content-1.jpg" alt="">
   </div>
  <div class="main-content">
    <div class="box" @click="goToDetail(item.id)" v-for="item of list" :key="item.id" >
      <div class="photo">
        <img :src="item.imgUrl" alt="">
      </div>
      <div class="text">{{item.title}}</div>
      <div class="main-footer">
        <em>￥</em>
        <b>{{item.price}}</b>
        <button>立即购买</button>
      </div>

    </div>

  </div>
</div>
</template>

<script>
export default {
  name: "FirstMain",
  data(){
    return{
      list:[
        {id:'001',price:'9.9', title:'幸福味道柴鸡蛋60枚 60枚/盒',imgUrl:require("@/assets/images/egg.png")},
        {id:'002',price:'9.9', title:'幸福味道柴鸡蛋60枚 60枚/盒',imgUrl:require("@/assets/images/huang.jpg")},
        {id:'003',price:'9.9', title:'幸福味道柴鸡蛋60枚 60枚/盒',imgUrl:require("@/assets/images/hulb.jpg")},
        {id:'004',price:'9.9', title:'幸福味道柴鸡蛋60枚 60枚/盒',imgUrl:require("@/assets/images/egg.png")}




      ]
    }
  },
  methods:{

    goToDetail(id){
      this.$router.push({path:'/detail' ,query:{id:id}})
    }
  }
}
</script>

<style scoped lang="scss">
.main{
  //margin-bottom: 200px;


  background-color: orange;

  height: 900px;
  .main-header{
    height: 150px;
  }
  .main-header img{
    width: 100%;
    height: 100%;
    background-size: cover;
  }
  .main-content{
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    .box{
      height: 300px;
      //margin-left: 10px;
      //margin-right: 10px;
      //padding-left: 5px;
      margin-top: 5px;
      background: white;
      //align-items: center;
      display: flex;
      align-items: center;
      flex-direction: column;
      justify-content: center;
      width: 48%;
      .photo{
        height: 200px;
        //width: 40%;
      }
      .photo img{
        height: 100%;
        width: 100%;
        background-size: cover;
      }
      .text{
        margin-top: 5px;
        margin-left: 5px;
      }
      .main-footer{
        display: flex;
        justify-content: center;
        align-items: center;
        //justify-content: space-between;
        margin-top: 8px;
      }

      .main-footer button{
        margin-left: 20px;
      }

    }
  }
}
</style>